package edu.neusoft.android.yuejian14.model;

import java.util.List;

import edu.neusoft.android.yuejian14.Listener.RetrofitListener;
import edu.neusoft.android.yuejian14.javabean.Video;
import edu.neusoft.android.yuejian14.service.RetrofitService;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static edu.neusoft.android.yuejian14.Const_Service.BASE_URL;

public class VideoModel {
    private Retrofit retrofit;
    public VideoModel(){
        //创建实例
        retrofit =new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }

    //俱乐部视频列表
    public void  getvideolistByClubId(String clubid,final RetrofitListener listener){
        RetrofitService retrofitService= retrofit.create(RetrofitService.class);
        Call<List<Video>> call = retrofitService.getvideolistByClubId(clubid);
        Callback<List<Video>> callback = new Callback<List<Video>>() {
            @Override
            public void onResponse(Call<List<Video>> call, Response<List<Video>> response) {

                List<Video> Video = response.body();

                listener.onSuccess(Video,1);
            }

            @Override
            public void onFailure(Call<List<Video>> call, Throwable t) {
                listener.onFail();

            }
        };
        call.enqueue(callback);
    }


}
